import os
from importlib import reload

mod_name = "test_mod.py"
with open(mod_name, "w") as f:
    f.write("data=123\n")
mod = __import__("test_mod")
print(mod.data)

with open(mod_name, "w") as f:
    f.write("data=456\n")
reload(mod)
print(mod.data)
os.remove(mod_name)
